package com.yanqu.road.server.cmd.activity.union.task;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.union.cross.CrossUnionActivityTaskProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.CrossUnionActivityTaskMgr;
import com.yanqu.road.server.protocol.CrossProtocol;

import java.util.List;

@Cmd(code = CrossProtocol.C2_UNION_ACTIVITY_TASK_UPLOAD_DATA, desc = "上传商会任务进度")
public class UploadUnionActivityTaskCmd extends CrossUnionCommand {

    private CrossUnionActivityTaskProto.SyncUnionActivityTaskMsg msg;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        msg = CrossUnionActivityTaskProto.SyncUnionActivityTaskMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        List<CrossUnionActivityTaskProto.UnionActivityTaskMsg> list = msg.getTaskListList();
        for (CrossUnionActivityTaskProto.UnionActivityTaskMsg taskMsg : list) {
            CrossUnionActivityTaskMgr.updateUnionActivityTaskData(msg.getActivityId(), taskMsg);
        }
    }

    @Override
    public void sendData() {

    }
}
